# ------------------- Frontiers paper ------------------------ #
#   Module:             Data construction       
#   Specifically:       Packages
#   Author:             Karsten, Mirko and Nina
# --------------------------------------------------------- #

packages_load <- function(install = FALSE) {
  # Vector of required packages
  libs <- c("readxl", "mudata2", "data.table", "sp", "stargazer", "tidyverse", 
            "dplyr", "lubridate", "survminer", "cowplot",
            "tidyr", "zoo", "RColorBrewer", "purrr", "lcmm", 
            "ggplot2", "reshape2")
  
  # Install packages
  if(install) {
    lapply(libs, install.packages)
  }
  
  # Load packages
  lapply(libs, library, character.only=T)
  
  # Clean up
  rm(libs)
}